#ifndef __MYSOCKET_H__
#define __MYSOCKET_H__

#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <signal.h>
#include <pthread.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <stdbool.h>
#include "sql.h"

typedef struct sockaddr Addr;
typedef struct sockaddr_in Addr_in;

extern pthread_mutex_t g_db_mutex;

#define BACKLOG 5
#define SERVER_PORT 8080
#define SERVER_LISTEN_IP "0.0.0.0"
#define ErrExit(msg) do {perror(msg);exit(EXIT_FAILURE);}while(0)
#define MAX_TOKEN_NUM 10

#define DATABASE_NAME "students.db"

typedef struct
{
    int fd;
    Addr_in sock;
    socklen_t sockLen;
}ConnectStruct_t;

void set_signal_handle(int sig);
void sig_handler(int sig);

int CreateSocket();

int string_format(const char* input, char* token[], int max_tonkens, const char* delimiters);

int recv_to_Send(const char* recv_buffer, size_t recv_size, char* send_buffer, size_t send_size);

#endif
